home *** CD-ROM | disk | FTP | other *** search
- Path: news.image.dk!usenet
- From: Poul Thomas Lomholt <davinci@image.dk>
- Newsgroups: comp.lang.c++
- Subject: Re: static and dynamic classes in C++ ?
- Date: Sat, 16 Mar 1996 15:36:41 +0100
- Organization: Da Vinci Data
- Message-ID: <314AD1F9.37A0@image.dk>
- References: <3148472F.41C6@informatik.uni-siegen.de>
- NNTP-Posting-Host: ip102.image.dk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Runu Knips wrote:
- >
- > Hi people!
- >
- > 1. Is it possible to declare a class in a way that only
- > dynamic instances of it may be declared ?
- >
- > 2. Is it also possible to declare a class in a way that
- > only static (i.e. stack or data segment) instances may
- > be declared ?
- >
- > Thanx you in advance for any answer :)
- >
- > Ciao
-
-
- Answ 1: Yes, make the destructor private, and use a "destroy"
- function (meking a "delete this") that must be called
- explicitly. This effectively stops any stack objects, because
- their destructor, if any, allways must be called when the object
- goes out of scope!
-
- For the answer on your second question I suggest you get the
- "More Effective C++", written by Scott Meyers. I know there is
- some information on these topics. I rememebered the first one,
- but not your second question!
-
- Ciao ciao
- Poul Thomas Lomholt
-